package no.ntnu.fp.net.Apps;

import java.net.InetAddress;
import java.util.Scanner;

import no.ntnu.fp.net.admin.Log;
import no.ntnu.fp.net.co.Connection;
import no.ntnu.fp.net.co.ConnectionImpl;
import no.ntnu.fp.net.co.ReceiveConnectionWorker;
import no.ntnu.fp.net.co.ReceiveMessageWorker;
import no.ntnu.fp.net.co.ReceiveMessageWorker.MessageListener;

public class MyClient implements MessageListener {
	private Connection connection;
	private ReceiveMessageWorker receiveMessageWorker;
	private boolean connected;
	
	
	public MyClient(int port) {
		connection = new ConnectionImpl(port);
		receiveMessageWorker = new ReceiveMessageWorker(connection);
		receiveMessageWorker.addMessageListener(this);
		connected = false;
		receiveMessageWorker.start();
	}


	@Override
	public void connectionClosed(Connection conn) {
		this.connection = null;
		this.connected = false;
		System.out.println("Connection closed...in client");
	}

	@Override
	public void messageReceived(String message) {
		System.out.println("MELDING MOTTATT: " + message);
	}

	public static void main(String[] args) {
		MyClient client = new MyClient(1337);
		System.out.println("IT CAN RUN");
	}

}
